<?php if ( !Cinnamon::inMode('ajax') || empty(Cinnamon::registry('params')->page) ): ?>
<div class="datagrid uicomponent" id="<?php echo $this->id; ?>">
	<div class="content">
<?php endif; ?>
		<?php if ( $this->getDataProvider() != null ): ?>
		<table class="<?php if ( $this->zebra ): echo 'zebra'; endif; ?>">
		<?php if ( $this->headers ): ?>
		<thead><tr>
		<?php foreach ( $this->getAllColumns() as $column ): ?>
		<th scope="col"<?php if ( is_numeric($column->width) ) { echo ' width="'. intval($column->width) .'"'; } ?>><?php echo $column ?></th>
		<?php endforeach; ?>
		</tr></thead>
		<?php endif; ?>
		<tbody>
		<?php foreach ( $this->getDataProvider() as $item ): ?>
		<tr>
		<?php 
			foreach ( $this->getAllColumns() as $key=>$column ):
				$cellValue = $this->getValueAt($item, $key);
				if ( $this->isNumeric($cellValue) ):
		?>
		<td class="numeric"><?php echo $cellValue; ?></td>
		<?php else: ?>
		<td><?php echo $cellValue; ?></td>
		<?php endif; endforeach; ?>
		</tr>
		<?php endforeach; ?>
		</tbody>
		</table>
		<?php endif; ?>
		<?php if ( $this->pagination ): 
					$ext = 4;
					$lowest  = $this->page - $ext;
					$highest = $this->page + $ext;

					if ( $highest > $this->pages ) {
						$lowest  = $lowest - ( $highest - $this->pages ) - 1;
						$highest = $this->pages;
					}
					if ( $lowest < 1 ) {
						$highest = $highest - $lowest + 1;
						$lowest  = 1;
					}
					$lowest  = max(1, $lowest);
					$highest = min($this->pages, $highest);

					if ( $lowest == 2 )
						$lowest--;
					if ( $highest == ($this->pages - 1) )
						$highest++;
		?>
		<div class="pages">
			<div class="active"><strong>Page</strong>: <?php echo $this->page; ?> of <?php echo $this->pages > 1000 ? '1000+' : $this->pages; ?></div>
			<ul class="list">
		<?php if ( $this->page > 1 ): $i = 1; ?>
				<?php /*
				<li><span class="ajax first" onclick="DataGrid.page('<?php echo $this->id; ?>', <?php echo $i; ?>);" title="Switch to page &ldquo;<?php echo $i; ?>&rdquo;"><?php echo '&laquo;'; ?></span></li>
				*/
				?>
				<?php $i = $this->page - 1; ?>
				<li><span class="ajax previous" onclick="DataGrid.page('<?php echo $this->id; ?>', <?php echo $i; ?>);" title="Switch to page &ldquo;<?php echo $i; ?>&rdquo;"><?php echo '&laquo'; ?></span></li>
		<?php endif; ?>
		<?php for ( $i=$lowest; $i<=$highest; $i++ ): ?>
				<li><span class="ajax<?php if ( $i == $this->page ): echo ' active'; endif; ?>" onclick="DataGrid.page('<?php echo $this->id; ?>', <?php echo $i; ?>);" title="Switch to page &ldquo;<?php echo $i; ?>&rdquo;"><?php echo $i; ?></span></li>
		<?php endfor; ?>
		<?php if ( $highest < $this->pages ): $i = $this->page + 1; ?>
				<li><span class="ajax next" onclick="DataGrid.page('<?php echo $this->id; ?>', <?php echo $i; ?>);" title="Switch to page &ldquo;<?php echo $i; ?>&rdquo;"><?php echo '&raquo'; ?></span></li>
				<?php $i = $this->pages; ?>
				<?php /*
				<li><span class="ajax last<?php if ( $i == $this->page ): echo ' active'; endif; ?>" onclick="DataGrid.page('<?php echo $this->id; ?>', <?php echo $i; ?>);" title="Switch to page &ldquo;<?php echo $i; ?>&rdquo;"><?php echo '&raquo;' ?></span></li> */ ?>
		<?php endif; ?>
			</ul>
			<div class="clear"> </div>	
		</div>
		<?php endif; ?>
		<?php if ( Cinnamon::inMode('ajax') ): ?>
		<script type="text/javascript">$('table.zebra tbody tr:nth-child(odd)').addClass('alt');</script>
		<?php endif; ?>	
<?php if ( !Cinnamon::inMode('ajax') || empty(Cinnamon::registry('params')->page) ): ?>
	</div>
</div>
<?php endif; ?>